//
//  MsgDetailViewController.m
//  DaDaBao
//
//  Created by admin on 15/8/20.
//  Copyright (c) 2015年 User. All rights reserved.
//

#import "MsgDetailViewController.h"

@interface MsgDetailViewController ()

@end

@implementation MsgDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self createUI];
    
    
}
//UI布局
-(void)createUI
{
    TopView *topView =[[TopView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, SCREEN_WIDTH, 64.0f)];
    [topView setTitile:@"站内通知"];
    [self.view addSubview:topView];
    UIButton *backBtn = [[UIButton alloc]initWithFrame:CGRectMake(0.0f, 20.0f, 64.0f, 44.0f)];
    [backBtn setBackgroundImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(buttonBackTapped:) forControlEvents:UIControlEventTouchUpInside];
    [topView addSubview:backBtn];
    
//  标题
    UILabel *titleLab = [[UILabel alloc] initWithFrame:CGRectMake(10.0f, 64.0f+10.0f, SCREEN_WIDTH-20.0f, 20.0f)];
    titleLab.font = [UIFont boldSystemFontOfSize:18.0f];
    titleLab.numberOfLines = 0;
    titleLab.text = self.msgTitle;
    titleLab.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:titleLab];
    
    float height = [UILabel height:titleLab.text widthOfFatherView:titleLab.frame.size.width textFont:titleLab.font]+0.1f;
    if (height>20.0f) {
        titleLab.frame = CGRectMake(10.0f, 64.0f+10.0f, SCREEN_WIDTH-20.0f, height);
    }
//日期
    UILabel *timeLab = [[UILabel alloc] initWithFrame:CGRectMake(10.0f, titleLab.frame.size.height+titleLab.frame.origin.y+10.0f, SCREEN_WIDTH-20.0f, 20.0f)];
    timeLab.font =[UIFont systemFontOfSize:15.0f];
    timeLab.textColor = [UIColor grayColor];
    timeLab.text = self.msgTime;
    timeLab.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:timeLab];
//    分割线
    UILabel *sepLab = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, timeLab.frame.size.height+timeLab.frame.origin.y+10.0f, SCREEN_WIDTH, 0.5f)];
    sepLab.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:sepLab];
//    内容
    UILabel *textLab = [[UILabel alloc] initWithFrame:CGRectMake(10.0f, sepLab.frame.size.height+sepLab.frame.origin.y+10.0f, SCREEN_WIDTH-20.0f, 20.0f)];
    textLab.font =[UIFont systemFontOfSize:17.0f];
    textLab.text = self.msgText;
    textLab.numberOfLines = 0;
    [self.view addSubview:textLab];

    float textHeight = [UILabel height:textLab.text widthOfFatherView:textLab.frame.size.width textFont:textLab.font]+0.01f;
    if (textHeight>20.0f) {
        textLab.frame = CGRectMake(10.0f, sepLab.frame.size.height+sepLab.frame.origin.y+10.0f, SCREEN_WIDTH-20.0f, textHeight);
    }

   
}



#pragma mark-返回方法
-(void)buttonBackTapped:(id)sender
{
    [self.navigationController popViewControllerAnimated:TRUE];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
